home *** CD-ROM | disk | FTP | other *** search
- /*
- File: macros.h
-
- Contains: Definition of various useful macros and inlines
-
- Written by: Arno Gourdol
-
- Copyright: © 1994-1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <3> 2/1/96 timbo Remove kScrollbarWidth; already defined in d11e1 headers.
- <2> 5/3/95 TM Merge with InfoAccess version.
- <1> 4/12/95 djc First checked in.
- <6> 3/28/95 RR Removed HiWord and LoWord functions
- <5> 10/27/94 RR added LowWord and HighWord Functions
- <4> 9/19/94 JwK Max macro should be pin
- <3> 7/25/94 JJ Removed String Macros
- <2> 7/25/94 JJ Added string macros
- <1> 7/15/94 arno first checked in
- <3> 7/14/94 arno Clean-up
- <1+> 6/10/94 arnoo Added PascalString macro
-
- */
-
- /*
- This file contains some frequently used macros:
-
- short min(short, short)
- short max(short, short)
- short pin(short value, short lowerBounds, short upperBound)
-
- long abs(long)
- long min(long, long)
- long max(long, long)
- long pin(long value, long lowerBounds, long upperBound)
-
- */
-
-
- #pragma once
-
- #ifndef __MACROS__
- #define __MACROS__
-
- #include <Types.h>
- #include <Memory.h>
-
- #ifdef __cplusplus
- //
- // C++ Versions of the macros
- //
-
- inline unsigned short HighWord(long l)
- {
- return (unsigned short)((l >> 16) & 0xFFFF);
- }
-
-
- inline unsigned short LowWord(long l)
- {
- return (unsigned short)(l & 0xFFFF);
- }
-
-
- inline short min(short a,
- short b)
- {
- return a > b ? b : a;
- }
-
-
- inline short max(short a,
- short b)
- {
- return a > b ? a : b;
- }
-
-
- inline long min(long a,
- long b)
- {
- return a > b ? b : a;
- }
-
-
- inline long max(long a,
- long b)
- {
- return a > b ? a : b;
- }
-
-
- inline short pin(short value,
- short min,
- short max)
- {
- return value < min ? min : (value > max ? max : value);
- }
-
-
- inline long pin(long value,
- long min,
- long max)
- {
- return value < min ? min : (value > max ? max : value);
- }
-
-
- inline short abs(short x)
- {
- return x < 0 ? -x : x;
- }
-
- inline long abs(long x)
- {
- return x < 0 ? -x : x;
- }
-
- #else
- //
- // C Versions of the macros
- //
-
- #ifndef min
- #define min(a,b) ((a)>(b)?(b):(a))
- #endif
-
- #ifndef max
- #define max(a,b) ((a)>(b)?(a):(b))
- #endif
-
- #ifndef pin
- #define pin(value,min,max) ((value) < (min) ? (min) : ((value) > (max) ? (max) : (value)))
- #endif
-
- #endif
-
-
- #endif